﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TravelLink.WebModel;

namespace TravelLink.WebApp.UserControl.Member {
    public partial class UC_Member_ModifyJob_Manager : ControlBase {
        protected void Page_Load(object sender, EventArgs e) {
            this.aspxResumeManager.DataSource = GetDataSource();
            this.aspxResumeManager.DataBind();
        }



        private List<ResumeView> GetDataSource() {
            var resumeList = this.DB.TL_Resume.Where(u => u.UserCode == this.CurrentUser.DBUser.UserCode);
            List<ResumeView> view = new List<ResumeView>();
            bool hasCn = false;
            int idx = 1;
            bool hasEn = false;
            foreach (var item in resumeList) {
                if (item.Language == 1) {
                    hasCn = true;
                }
                else if (item.Language == 2) {
                    hasEn = true;
                }

                view.Add(new ResumeView {
                    Idx = idx,
                    CreateDate = item.RowTime.Value.ToString("yyyy/MM/dd"),
                    Name = item.Language == 1 ? "中文简历" : "英文简历",
                    EditUrl = item.Language == 1 ? "MemberModifyJob_CN.aspx" : "MemberModifyJob_EN.aspx"
                });
                idx++;
            }

            if (!hasCn) {
                view.Add(new ResumeView {
                    Idx = idx,
                    CreateDate = "尚未完善",
                    Name = "中文简历",
                    EditUrl = "MemberModifyJob_CN.aspx"
                });
                idx++;
            }
            if (!hasEn) {
                view.Add(new ResumeView {
                    Idx = idx,
                    CreateDate = "尚未完善",
                    Name = "英文简历",
                    EditUrl = "MemberModifyJob_EN.aspx"
                });
            }
            return view;

        }
    }


    public class ResumeView {
        public int Idx { get; set; }

        public string Name { get; set; }

        public string CreateDate { get; set; }

        public string EditUrl { get; set; }

    }
}